#pragma once

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

#include "../systicket/systicket.h"

#define m_systempause_start(time_interval)                \
  {                                                       \
    static ticket_ms_t last_time;                         \
    if (m_get_ticket_ms() - last_time >= time_interval) { \
      last_time = m_get_ticket_ms();

#define m_systempause_end() \
  }                         \
  }

//标准宏函数
#define MATH_MIN(A,B)                   (((A) > (B)) ? (B) : (A))
#define MATH_MAX(A,B)                   (((A) < (B)) ? (B) : (A))
#define MATH_ABS_SUB(A,B)               (((A) > (B)) ? ((A) - (B)) : ((B) - (A)))
#define MATH_ABS_VAL(A)                 (((A) > 0)   ? (A) : (-(A)))
#define CHECKBIT(Val, bit)              (((Val) & (bit)) == (bit))
#define MATH_ABS2(A,B)                   (((A) > (B)) ? ((A) - (B)) : ((B) - (A)))
#define MATH_ABS2_VAR(A)                 (((A) > 0)   ? (A) : (-(A)))
#define MATH_ABS(A)                     (((A) > 0)   ? (A) : (-(A)))